﻿Imports Cls_Common
Imports VSModel
Partial Class Control_BanHang_InHoaDon
    Inherits System.Web.UI.UserControl
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If Not Request.QueryString("Id").ToString.Equals("0") Then
                hidID.Value = Request.QueryString("Id")
                ShowData()
            End If
        End If
    End Sub
    Protected Sub ShowData()
        Using data As New VSEntities
            Dim p As BanHang = (From q In data.BanHangs Where q.Id = hidID.Value Select q).SingleOrDefault
            If Not p Is Nothing Then

                If Not p.GrossAmount Is Nothing Then
                    lblGrossAmount.Text = CType(p.GrossAmount, Double).ToString("##,###")
                End If

                Dim d = (From q In data.BanHangDetails Where q.BanHangId = p.Id Select New With {q.BanHangId, q.ProductCode, q.Product.SellPrice, q.Product.Title, q.Number, .GrossAmount = q.GrossAmount}).ToList
                Dim strKey_Name() As String = {"BanHangId"}
                With grdShow
                    .DataKeyNames = strKey_Name
                    .DataSource = d
                    .DataBind()
                End With

            End If
        End Using
    End Sub
End Class
